import { ScrollView, View } from "@tarojs/components";
import {
  Form,
  Tabs,
  Cell,
  Input,
  Button,
  Textarea,
  Tag,
  Pagination,
  Popup,
  Radio,
  Toast,
  Dialog,
  Calendar,
} from "@taroify/core";

import HeaderSearch from "@/components/HeaderSearch/index";
import Header from "@/components/Header/index";
import GoodsTitle from "@/components/GoodsTitle/index";
import Footer from "@/components/Footer/index";
import { useEffect, useRef, useState } from "react";
import { requestPOST } from "@/request";
import { useDispatch, useSelector } from "react-redux";
import { RootState } from "@/store";
import { setShopInfo } from "@/store/reducers/userInfo";

export default function Index() {
  const shopInfo = useSelector((state: RootState) => state.userInfo.shopInfo);
  const userInfo = useSelector((state: RootState) => state.userInfo.userInfo);
  // const dispatch = useDispatch();

  const [form1, setForm1] = useState<any>({
    username: shopInfo.userName,
    phone: shopInfo.phone,
    email: shopInfo.email,
    address: shopInfo.address,
    isEnquiriesEmail: shopInfo.isEnquiriesEmail ? 1 : 0,
    isOrderEmail: shopInfo.isOrderEmail ? 1 : 0,
  });

  const [open, setOpen] = useState(false);
  const [form2, setForm2] = useState<any>({
    id: null,
    address: "",
    confirmPassword: "",
    email: "",
    password: "",
    phone: "",
    status: 0,
    userName: "",
  });
  const [personList, setPersonList] = useState<any>([]);
  const [current, setCurrent] = useState(1);
  const [count, setCount] = useState(0);
  const handleChange = (page) => {
    setCurrent(page);
    getPersonList(page);
  };

  const getPersonList = (page?: number) => {
    requestPOST("shop/shopSubAccountList", {
      pageTotal: 1,
      pageNum: page || current,
      pageSize: 6,
    }).then((res: any) => {
      setCount(Math.ceil(res.total / 6));
      setPersonList([...res.vos]);
    });
  };
  const editPerson = (item) => {
    setForm2({ ...form2, ...item });
    setOpen(true);
  };
  const delPerson = (item) => {
    Dialog.confirm({
      title: "提示",
      message: "您确定要删除吗？",
      onConfirm() {
        requestPOST(`shop/shopDelSubAccount/${item.id}`).then(() => {
          Toast.open({ type: "success", message: "删除成功" });
          getPersonList();
        });
      },
    });
  };
  const onSubmit1 = () => {
    requestPOST("shop/editShopMyInfo", { ...shopInfo, ...form1 }).then(() => {
      Toast.open({ type: "success", message: "修改成功" });
    });
  };
  const onSubmit2 = () => {
    requestPOST(
      form2.id ? "shop/shopEditSubAccount" : "shop/shopAddSubAccount",
      { ...form2 }
    ).then(() => {
      Toast.open({
        type: "success",
        message: form2.id ? "修改成功" : "添加成功",
      });
      setOpen(false);
      clearForm2();
      getPersonList();
    });
  };
  const clearForm2 = () => {
    setForm2({
      id: null,
      address: "",
      confirmPassword: "",
      email: "",
      password: "",
      phone: "",
      status: 0,
      userName: "",
    });
    formRef2.current?.reset();
  };

  const [current1, setCurrent1] = useState(1);
  const [count1, setCount1] = useState(0);
  const [couponList, setCouponList] = useState<any>([]);
  const [open1, setOpen1] = useState(false);
  const [openTime, setOpenTime] = useState(false);
  const [time, setTime] = useState<Date>();
  const [form3, setForm3] = useState<any>({
    id: "",
    status: 1,
    couponName: "",
    describeDetail: "",
    fullAmount: "",
    denomination: "",
    quantity: "",
    endTime: null,
    isReceive: 1,
    quantityReceived: "",
  });

  const getCouponList = (page?: number) => {
    requestPOST("shop/shopCouponList", {
      pageTotal: 1,
      pageNum: page || current1,
      pageSize: 6,
    }).then((res: any) => {
      setCount1(Math.ceil(res.total / 6));
      setCouponList([...res.vos]);
    });
  };
  const handleChange1 = (page) => {
    setCurrent1(page);
    getCouponList(page);
  };
  const setStauts = (item) => {
    requestPOST(`shop/shopCouponOpenOrClose/${item.id}`).then(() => {
      Toast.open({ type: "success", message: "操作成功" });
      getCouponList();
    });
  };
  const onSubmit3 = () => {
    if (!form3.endTime) {
      return Toast.open({ type: "fail", message: "请选择结束日期" });
    }
    requestPOST(form3.id ? "shop/shopEditCoupon" : "shop/shopAddCoupon", {
      ...form3,
    }).then(() => {
      Toast.open({
        type: "success",
        message: form3.id ? "修改成功" : "添加成功",
      });
      setOpen1(false);
      clearForm3();
      getCouponList();
    });
  };
  const clearForm3 = () => {
    setForm3({
      id: "",
      status: 1,
      couponName: "",
      describeDetail: "",
      fullAmount: "",
      denomination: "",
      quantity: "",
      endTime: null,
      isReceive: 1,
      quantityReceived: "",
    });
    formRef3.current?.reset();
  };
  const editCoupon = (item) => {
    setForm3({ ...form3, ...item, endTime: new Date(item.endTime) });
    setTime(new Date(item.endTime));
    setOpen1(true);
    getCouponList();
  };

  const formmateDate = (date: Date) => {
    if (!date) return;
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const date1 = date.getDate();

    return `${year}/${month}/${date1}`;
  };
  const delCoupon = (item) => {
    Dialog.confirm({
      title: "提示",
      message: "您确定要删除吗？",
      onConfirm() {
        requestPOST(`shop/shopDelCoupon/${item.id}`).then(() => {
          Toast.open({ type: "success", message: "删除成功" });
          getCouponList();
        });
      },
    });
  };

  const [form4, setForm4] = useState({
    email: shopInfo.email,
    oldPwd: "",
    pwd: "",
    confirmPwd: "",
    code: "",
  });
  const [forget, setForget] = useState(true);
  const [time1, setTime1] = useState<number>(0);
  let timer;
  const sendEmailCode = () => {
    if (!form4.email) {
      return Toast.open({ type: "fail", message: "请输入邮箱" });
    }
    requestPOST(`other/pwdGetCode/${form4.email}`).then(() => {
      Toast.open({ type: "success", message: "发送成功" });
      let time = 60;
      timer = setInterval(() => {
        if (time <= 0) {
          clearInterval(timer);
        }
        setTime1(--time);
      }, 1000);
    });
  };

  const onSubmit4 = () => {
    if (form4.pwd !== form4.confirmPwd) {
      return Toast.open({ type: "fail", message: "两次密码不一致" });
    }
    requestPOST(forget ? "other/userUpdatePwd" : "other/userForgetPwd", {
      ...form4,
      accountEmail: form4.email,
    }).then(() => {
      Toast.open({ type: "success", message: "修改成功" });
      setForm4({
        email: shopInfo.email,
        oldPwd: "",
        pwd: "",
        confirmPwd: "",
        code: "",
      });
      formRef1.current?.reset();
    });
  };

  const businessId = useSelector(
    (state: RootState) => state.business.businessId
  );
  const [open2, setOpen2] = useState(false);
  const [form5, setForm5] = useState({
    userName: "",
    email: "",
    phone: "",
    businessId: "",
    childBusinessCoupon: 0,
    childBusinessIntroduct: 0,
    childBusinessQualification: 0,
    childBusinessPayType: 0,
    childBusinessPdocutType: 0,
    childBusinessProduct: 0,
    childBusinessOrder: 0,
    childBusinessInquirycenter: 0,
    childBusinessFeedback: 0,
    childBusinessContactUs: 0,
    childBusinessShopCart: 0,
    childBusinessPromotion: 0,
    childBusinessOtherSystem: 0,
    id: "",
  });

  const toaozheng = (item) => {
    requestPOST(`shop/getPermissionsInfoByChildUser/${item.id}`).then(
      (res: any) => {
        setForm5({
          ...res,
          id: item.id,
          userName: item.userName,
          email: item.email,
          phone: item.phone,
        });
        setOpen2(true);
      }
    );
  };

  const onSubmit5 = () => {
    requestPOST("shop/updateChildUserPermissionsInfo", { ...form5 }).then(
      () => {
        setOpen2(false);
        Toast.open({ type: "success", message: "保存成功" });
        clearForm5();
      }
    );
  };

  const [showList, setShowList] = useState<any>({
    childBusinessCoupon: 1,
    childBusinessIntroduct: 1,
    childBusinessQualification: 1,
    childBusinessPayType: 1,
    childBusinessPdocutType: 1,
    childBusinessProduct: 1,
    childBusinessOrder: 1,
    childBusinessInquirycenter: 1,
    childBusinessFeedback: 1,
    childBusinessContactUs: 1,
    childBusinessShopCart: 1,
    childBusinessPromotion: 1,
    childBusinessOtherSystem: 1,
  });

  const getShowList = () => {
    requestPOST("shop/getNowChildBusinessPermissionsInfo").then((res: any) => {
      setShowList({ ...res });
      if (res.childBusinessCoupon) {
        getCouponList();
      }
    });
  };

  const clearForm5 = () => {
    setForm5({
      userName: "",
      email: "",
      phone: "",
      businessId: "",
      childBusinessCoupon: 0,
      childBusinessIntroduct: 0,
      childBusinessQualification: 0,
      childBusinessPayType: 0,
      childBusinessPdocutType: 0,
      childBusinessProduct: 0,
      childBusinessOrder: 0,
      childBusinessInquirycenter: 0,
      childBusinessFeedback: 0,
      childBusinessContactUs: 0,
      childBusinessShopCart: 0,
      childBusinessPromotion: 0,
      childBusinessOtherSystem: 0,
      id: "",
    });
    formRef4.current?.reset();
  };

  useEffect(() => {
    if (userInfo?.accountType == 2) {
      getShowList();
    } else {
      getPersonList();
      getCouponList();
    }
  }, []);
  const formRef = useRef<any>();
  const formRef1 = useRef<any>();
  const formRef2 = useRef<any>();
  const formRef3 = useRef<any>();
  const formRef4 = useRef<any>();

  return (
    <View className="taroBox">
      <HeaderSearch />
      <Header />
      <GoodsTitle title="基本信息" isMore={false} />
      <Tabs ellipsis={false}>
        <Tabs.TabPane title="贸易商信息">
          <Form ref={formRef} defaultValues={form1} onSubmit={onSubmit1}>
            <Cell.Group inset>
              <Form.Item name="username">
                <Form.Label>姓名</Form.Label>
                <Form.Control>
                  <Input value={form1.username} readonly />
                </Form.Control>
              </Form.Item>
              <Form.Item name="phone">
                <Form.Label>手机号</Form.Label>
                <Form.Control>
                  <Input value={form1.phone} readonly />
                </Form.Control>
              </Form.Item>
              <Form.Item name="email">
                <Form.Label>邮箱地址</Form.Label>
                <Form.Control>
                  <Input value={form1.email} readonly />
                </Form.Control>
              </Form.Item>
              <Form.Item
                name="address"
                rules={[{ required: true, message: "请填写地址" }]}
              >
                <Form.Label>地址</Form.Label>
                <Form.Control>
                  <Textarea
                    value={form1.address}
                    onChange={(e) =>
                      setForm1({ ...form1, address: e.detail.value })
                    }
                    style={{ height: "5rem" }}
                    limit={255}
                  ></Textarea>
                </Form.Control>
              </Form.Item>
              <Form.Item name="isEnquiriesEmail">
                <Form.Label>接受询盘邮件</Form.Label>
                <Form.Control>
                  <Radio.Group
                    value={form1.isEnquiriesEmail}
                    onChange={(value) =>
                      setForm1({ ...form1, isEnquiriesEmail: value })
                    }
                  >
                    <Radio name={1}>是</Radio>
                    <Radio name={0}>否</Radio>
                  </Radio.Group>
                </Form.Control>
              </Form.Item>
              <Form.Item name="isOrderEmail">
                <Form.Label>接受订单邮件</Form.Label>
                <Form.Control>
                  <Radio.Group
                    value={form1.isOrderEmail}
                    onChange={(value) =>
                      setForm1({ ...form1, isOrderEmail: value })
                    }
                  >
                    <Radio name={1}>是</Radio>
                    <Radio name={0}>否</Radio>
                  </Radio.Group>
                </Form.Control>
              </Form.Item>
            </Cell.Group>
            <View style={{ margin: "1rem" }}>
              <Button shape="round" block color="primary" formType="submit">
                提交
              </Button>
            </View>
          </Form>
        </Tabs.TabPane>
        {userInfo?.accountType != 2 && (
          <Tabs.TabPane title="员工管理">
            <View style={{ padding: ".875rem" }}>
              <Button
                color="primary"
                size="small"
                onClick={() => setOpen(true)}
              >
                添加
              </Button>
              <View
                style={{
                  marginTop: ".875rem",
                  display: "flex",
                  flexDirection: "column",
                  gap: "1.25rem",
                }}
              >
                {personList.map((item) => (
                  <View
                    key={item.id}
                    style={{
                      position: "relative",
                      fontSize: ".875rem",
                      boxShadow: "0 0 .3125rem 0 hsla(0, 0%, 49%, 0.45)",
                      padding: ".875rem",
                    }}
                  >
                    <Tag
                      style={{
                        position: "absolute",
                        right: ".625rem",
                        top: ".625rem",
                      }}
                      color="primary"
                    >
                      {item.status == 1 ? "正式" : "非正式"}
                    </Tag>
                    <View>
                      序号.{item.id} {item.userName}
                    </View>
                    <View>电话:{item.phone}</View>
                    <View>邮箱:{item.email}</View>
                    <View style={{ marginTop: ".625rem" }}>
                      <Button
                        size="small"
                        color="primary"
                        variant="outlined"
                        onClick={() => editPerson(item)}
                      >
                        修改
                      </Button>
                      <Button
                        size="small"
                        color="danger"
                        variant="outlined"
                        style={{ marginLeft: "1.25rem" }}
                        onClick={() => delPerson(item)}
                      >
                        删除
                      </Button>
                      <Button
                        size="small"
                        color="info"
                        variant="outlined"
                        style={{ marginLeft: "1.25rem" }}
                        onClick={() => toaozheng(item)}
                      >
                        调整权限
                      </Button>
                    </View>
                  </View>
                ))}
              </View>
              <View style={{ marginBlock: "1.25rem", padding: "0 .875rem" }}>
                <Pagination
                  current={current}
                  siblingCount={1}
                  count={count}
                  onChange={(page) => handleChange(page)}
                >
                  <Pagination.Item type="start-ellipsis" />
                  <Pagination.Item type="end-ellipsis" />
                </Pagination>
              </View>
            </View>
          </Tabs.TabPane>
        )}
        {Boolean(showList?.childBusinessCoupon) && (
          <Tabs.TabPane title="优惠卷管理">
            <View style={{ padding: ".875rem" }}>
              <Button
                color="primary"
                size="small"
                onClick={() => setOpen1(true)}
              >
                添加
              </Button>
              <View
                style={{
                  marginTop: ".875rem",
                  display: "flex",
                  flexDirection: "column",
                  gap: "1.25rem",
                }}
              >
                {couponList.map((item) => (
                  <View
                    key={item.id}
                    style={{
                      position: "relative",
                      fontSize: ".875rem",
                      boxShadow: "0 0 .3125rem 0 hsla(0, 0%, 49%, 0.45)",
                      padding: ".875rem",
                    }}
                  >
                    <Tag
                      style={{
                        position: "absolute",
                        right: ".625rem",
                        top: ".625rem",
                      }}
                      color="primary"
                    >
                      {item.status == 1 ? "启用" : "禁用"}
                    </Tag>
                    <View>{item.couponName}</View>
                    <View>金额:${item.denomination}</View>
                    <View>可用:${item.fullAmount}</View>
                    <View>结束时间:{item.endTime}</View>
                    <View style={{ marginTop: ".625rem" }}>
                      <Button
                        size="small"
                        color="primary"
                        variant="outlined"
                        onClick={() => editCoupon(item)}
                        disabled={item.status === 1}
                      >
                        修改
                      </Button>
                      <Button
                        size="small"
                        color="danger"
                        variant="outlined"
                        style={{ marginLeft: "1.25rem" }}
                        onClick={() => delCoupon(item)}
                      >
                        删除
                      </Button>
                      <Button
                        size="small"
                        color="primary"
                        variant="outlined"
                        style={{ marginLeft: "1.25rem" }}
                        onClick={() => setStauts(item)}
                      >
                        {item.status === 1 ? "禁用" : "启用"}
                      </Button>
                    </View>
                  </View>
                ))}
              </View>
              <View style={{ marginBlock: "1.25rem", padding: "0 .875rem" }}>
                <Pagination
                  current={current1}
                  siblingCount={1}
                  count={count1}
                  onChange={(page) => handleChange1(page)}
                >
                  <Pagination.Item type="start-ellipsis" />
                  <Pagination.Item type="end-ellipsis" />
                </Pagination>
              </View>
            </View>
          </Tabs.TabPane>
        )}
        {userInfo?.accountType != 2 && (
          <Tabs.TabPane title="修改密码">
            <Form ref={formRef1} defaultValues={form4} onSubmit={onSubmit4}>
              <Cell.Group inset>
                <Form.Item name="email">
                  <Form.Label>邮箱</Form.Label>
                  <Form.Control>
                    <Input value={form4.email} readonly />
                  </Form.Control>
                </Form.Item>
                {forget ? (
                  <Form.Item
                    name="oldPwd"
                    rules={[{ required: forget, message: "请填写原密码" }]}
                  >
                    <Form.Label>原密码</Form.Label>
                    <Form.Control>
                      <Input
                        value={form4.oldPwd}
                        password
                        onChange={(e) =>
                          setForm4({ ...form4, oldPwd: e.detail.value })
                        }
                      />
                    </Form.Control>
                  </Form.Item>
                ) : (
                  <Form.Item
                    name="code"
                    rules={[{ required: !forget, message: "请填写验证码" }]}
                  >
                    <Form.Label>验证码</Form.Label>
                    <Form.Control>
                      <Input
                        value={form4.code}
                        password
                        onChange={(e) =>
                          setForm4({ ...form4, code: e.detail.value })
                        }
                      />
                      <Button
                        disabled={time1 > 0}
                        onClick={() => sendEmailCode()}
                        color="primary"
                        size="small"
                      >
                        {time1 > 0 ? time1 + "s" : "获取验证码"}
                      </Button>
                    </Form.Control>
                  </Form.Item>
                )}

                <Form.Item
                  name="pwd"
                  rules={[{ required: true, message: "请填写新密码" }]}
                >
                  <Form.Label>新密码</Form.Label>
                  <Form.Control>
                    <Input
                      value={form4.pwd}
                      password
                      onChange={(e) =>
                        setForm4({ ...form4, pwd: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="confirmPwd"
                  rules={[{ required: true, message: "请填写确认密码" }]}
                >
                  <Form.Label>确认密码</Form.Label>
                  <Form.Control>
                    <Input
                      value={form4.confirmPwd}
                      password
                      onChange={(e) =>
                        setForm4({ ...form4, confirmPwd: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
              </Cell.Group>
              <View
                style={{
                  margin: "10px 40px 10px 40px",
                  textAlign: "right",
                }}
              >
                <Button
                  onClick={() => setForget(!forget)}
                  variant="outlined"
                  color="primary"
                  size="small"
                >
                  {forget ? "忘记密码" : "修改密码"}
                </Button>
              </View>
              <View style={{ margin: "1rem" }}>
                <Button shape="round" block color="primary" formType="submit">
                  提交
                </Button>
              </View>
            </Form>
          </Tabs.TabPane>
        )}
      </Tabs>
      <Footer />

      <Popup
        open={open}
        placement="center"
        style={{ height: "auto" }}
        rounded
        lock={false}
      >
        <ScrollView style={{ maxHeight: "90vh" }} scrollY>
          <View style={{ width: "90vw", padding: "14px 0" }}>
            <Form ref={formRef2} defaultValues={form2} onSubmit={onSubmit2}>
              <Cell.Group inset>
                <Form.Item
                  name="userName"
                  rules={[{ required: true, message: "姓名" }]}
                >
                  <Form.Label>姓名</Form.Label>
                  <Form.Control>
                    <Input
                      value={form2.userName}
                      placeholder="姓名"
                      onChange={(e) =>
                        setForm2({ ...form2, userName: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="email"
                  rules={[{ required: true, message: "邮箱" }]}
                >
                  <Form.Label>邮箱</Form.Label>
                  <Form.Control>
                    <Input
                      value={form2.email}
                      placeholder="邮箱"
                      onChange={(e) =>
                        setForm2({ ...form2, email: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="phone"
                  rules={[{ required: true, message: "手机号" }]}
                >
                  <Form.Label>手机号</Form.Label>
                  <Form.Control>
                    <Input
                      value={form2.phone}
                      placeholder="手机号"
                      onChange={(e) =>
                        setForm2({ ...form2, phone: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="password"
                  rules={[{ required: true, message: "密码" }]}
                >
                  <Form.Label>密码</Form.Label>
                  <Form.Control>
                    <Input
                      password
                      value={form2.password}
                      placeholder="密码"
                      onChange={(e) =>
                        setForm2({ ...form2, password: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="confirmPassword"
                  rules={[{ required: true, message: "确认密码" }]}
                >
                  <Form.Label>确认密码</Form.Label>
                  <Form.Control>
                    <Input
                      password
                      value={form2.confirmPassword}
                      placeholder="确认密码"
                      onChange={(e) =>
                        setForm2({ ...form2, confirmPassword: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="status"
                  rules={[{ required: true, message: "状态" }]}
                >
                  <Form.Label>状态</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form2.status}
                      onChange={(value) =>
                        setForm2({ ...form2, status: value })
                      }
                    >
                      <Radio name={1}>正式</Radio>
                      <Radio name={0}>非正式</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="address"
                  rules={[{ required: true, message: "地址" }]}
                >
                  <Form.Label>地址</Form.Label>
                  <Form.Control>
                    <Textarea
                      value={form2.address}
                      onChange={(e) =>
                        setForm2({ ...form2, address: e.detail.value })
                      }
                      style={{ height: "5rem" }}
                      limit={255}
                    />
                  </Form.Control>
                </Form.Item>
              </Cell.Group>
              <View
                style={{
                  margin: "1rem",
                  display: "flex",
                  alignItems: "center",
                  gap: "30px",
                }}
              >
                <Button
                  shape="round"
                  block
                  color="primary"
                  variant="outlined"
                  onClick={() => {
                    clearForm2();
                    setOpen(false);
                  }}
                >
                  取消
                </Button>
                <Button shape="round" block color="primary" formType="submit">
                  提交
                </Button>
              </View>
            </Form>
          </View>
        </ScrollView>
      </Popup>

      <Popup open={open1} placement="center" style={{ height: "auto" }} rounded>
        <ScrollView style={{ maxHeight: "90vh" }} scrollY>
          <View style={{ width: "90vw", padding: "14px 0" }}>
            <Form ref={formRef3} defaultValues={form3} onSubmit={onSubmit3}>
              <Cell.Group inset>
                <Form.Item
                  name="couponName"
                  rules={[{ required: true, message: "名字" }]}
                >
                  <Form.Label>名字</Form.Label>
                  <Form.Control>
                    <Input
                      value={form3.couponName}
                      placeholder="名字"
                      onChange={(e) =>
                        setForm3({ ...form3, couponName: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="describeDetail"
                  rules={[{ required: true, message: "描述信息" }]}
                >
                  <Form.Label>描述信息</Form.Label>
                  <Form.Control>
                    <Input
                      value={form3.describeDetail}
                      placeholder="描述信息"
                      onChange={(e) =>
                        setForm3({ ...form3, describeDetail: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="denomination"
                  rules={[{ required: true, message: "金额" }]}
                >
                  <Form.Label>金额</Form.Label>
                  <Form.Control>
                    <Input
                      value={form3.denomination}
                      placeholder="金额"
                      onChange={(e) =>
                        setForm3({ ...form3, denomination: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="fullAmount"
                  rules={[{ required: true, message: "满减金额" }]}
                >
                  <Form.Label>满减金额</Form.Label>
                  <Form.Control>
                    <Input
                      value={form3.fullAmount}
                      placeholder="满减金额"
                      onChange={(e) =>
                        setForm3({ ...form3, fullAmount: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="quantity"
                  rules={[{ required: true, message: "数量" }]}
                >
                  <Form.Label>数量</Form.Label>
                  <Form.Control>
                    <Input
                      value={form3.quantity}
                      placeholder="数量"
                      onChange={(e) =>
                        setForm3({ ...form3, quantity: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="endTime"
                  rules={[{ required: false, message: "结束日期" }]}
                >
                  <Form.Control>
                    <Cell
                      style={{ padding: "0px" }}
                      title="结束日期"
                      isLink
                      children={formmateDate(form3.endTime)}
                      onClick={() => setOpenTime(true)}
                    />
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="isReceive"
                  rules={[{ required: true, message: "限领状态" }]}
                >
                  <Form.Label>限领状态</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form3.isReceive}
                      onChange={(value) =>
                        setForm3({ ...form3, isReceive: value })
                      }
                    >
                      <Radio name={1}>限领</Radio>
                      <Radio name={0}>不限领</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="status"
                  rules={[{ required: true, message: "状态" }]}
                >
                  <Form.Label>状态</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form3.status}
                      onChange={(value) =>
                        setForm3({ ...form3, status: value })
                      }
                    >
                      <Radio name={1}>启用</Radio>
                      <Radio name={0}>禁用</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item
                  name="quantityReceived"
                  rules={[{ required: true, message: "限领数量" }]}
                >
                  <Form.Label>限领数量</Form.Label>
                  <Form.Control>
                    <Input
                      value={form3.quantityReceived}
                      placeholder="限领数量"
                      onChange={(e) =>
                        setForm3({ ...form3, quantityReceived: e.detail.value })
                      }
                    />
                  </Form.Control>
                </Form.Item>
              </Cell.Group>
              <View
                style={{
                  margin: "1rem",
                  display: "flex",
                  alignItems: "center",
                  gap: "30px",
                }}
              >
                <Button
                  shape="round"
                  block
                  color="primary"
                  variant="outlined"
                  onClick={() => {
                    clearForm3();
                    setOpen1(false);
                  }}
                >
                  取消
                </Button>
                <Button shape="round" block color="primary" formType="submit">
                  提交
                </Button>
              </View>
            </Form>
          </View>
        </ScrollView>
      </Popup>

      <Calendar
        className="taroBox1"
        type="single"
        value={time}
        poppable
        showPopup={openTime}
        onClose={setOpenTime}
        onChange={setTime}
        onConfirm={(newValue: Date) => {
          setForm3({ ...form3, endTime: newValue });
          setOpenTime(false);
        }}
      ></Calendar>

      <Popup
        open={open2}
        placement="center"
        style={{ height: "auto" }}
        rounded
        onClose={() => {
          clearForm5();
          setOpen2(false);
        }}
        lock={false}
      >
        <ScrollView style={{ maxHeight: "90vh" }} scrollY>
          <View style={{ width: "90vw", padding: "14px 0" }}>
            <Form ref={formRef4} defaultValues={form5} onSubmit={onSubmit5}>
              <Cell.Group inset>
                <Form.Item
                  name="userName"
                  rules={[{ required: true, message: "姓名" }]}
                >
                  <Form.Label>姓名</Form.Label>
                  <Form.Control>{form5.userName}</Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>邮箱</Form.Label>
                  <Form.Control>{form5.email}</Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>手机号</Form.Label>
                  <Form.Control>{form5.phone}</Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>优惠卷</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessCoupon}
                      onChange={(value) =>
                        setForm5({ ...form5, childBusinessCoupon: value })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>企业简介</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessIntroduct}
                      onChange={(value) =>
                        setForm5({ ...form5, childBusinessIntroduct: value })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>企业资质</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessQualification}
                      onChange={(value) =>
                        setForm5({
                          ...form5,
                          childBusinessQualification: value,
                        })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>支付方式</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessPayType}
                      onChange={(value) =>
                        setForm5({ ...form5, childBusinessPayType: value })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>产品分类</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessPdocutType}
                      onChange={(value) =>
                        setForm5({ ...form5, childBusinessPdocutType: value })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>产品管理</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessProduct}
                      onChange={(value) =>
                        setForm5({ ...form5, childBusinessProduct: value })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>订单管理</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessOrder}
                      onChange={(value) =>
                        setForm5({ ...form5, childBusinessOrder: value })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>询盘管理</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessInquirycenter}
                      onChange={(value) =>
                        setForm5({
                          ...form5,
                          childBusinessInquirycenter: value,
                        })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>反馈信息</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessFeedback}
                      onChange={(value) =>
                        setForm5({
                          ...form5,
                          childBusinessFeedback: value,
                        })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>联系我们</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessContactUs}
                      onChange={(value) =>
                        setForm5({
                          ...form5,
                          childBusinessContactUs: value,
                        })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>购物车管理</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessShopCart}
                      onChange={(value) =>
                        setForm5({
                          ...form5,
                          childBusinessShopCart: value,
                        })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>推广管理</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessPromotion}
                      onChange={(value) =>
                        setForm5({
                          ...form5,
                          childBusinessPromotion: value,
                        })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
                <Form.Item>
                  <Form.Label>贸易管理</Form.Label>
                  <Form.Control>
                    <Radio.Group
                      value={form5.childBusinessOtherSystem}
                      onChange={(value) =>
                        setForm5({
                          ...form5,
                          childBusinessOtherSystem: value,
                        })
                      }
                    >
                      <Radio name={1}>继承权限</Radio>
                      <Radio name={0}>不继承</Radio>
                    </Radio.Group>
                  </Form.Control>
                </Form.Item>
              </Cell.Group>
              <View
                style={{
                  margin: "1rem",
                  display: "flex",
                  alignItems: "center",
                  gap: "30px",
                }}
              >
                <Button
                  shape="round"
                  block
                  color="primary"
                  variant="outlined"
                  onClick={() => {
                    clearForm5();
                    setOpen2(false);
                  }}
                >
                  取消
                </Button>
                <Button shape="round" block color="primary" formType="submit">
                  提交
                </Button>
              </View>
            </Form>
          </View>
        </ScrollView>
      </Popup>
    </View>
  );
}
